//click_script.sqf
#include "ACV_constantes.h"
#include "ACV_ID_main_dlg.h"
private ["_entry","_code"];
disableserialization;
switch (_this select 0) do {
	case "list" : {
		ACV_Mode_Script = ! ACV_Mode_Script;
		if (ACV_Mode_Script) then {
			call ACV_FNCT_ShowScript;
		} else {
			call ACV_FNCT_HideScript;
		};
	};
	case "category" : {
		ACV_Default_Script_category = lbCurSel ACV_DLG_ID_Script_Categories;
		[] call ACV_FNCT_Fill_Functions;
	};
	case "function" : {
		ACV_Default_Script_function = lbCurSel ACV_DLG_ID_Script_List;
		[] call ACV_FNCT_Fill_Script_Help;
	};
	case "run" : {
		ACV_Default_Script = ctrlText ACV_DLG_ID_Script_Edit;
		[] spawn {call compile ACV_Default_Script;};
		[format[localize "STR_MSG_SCRIPTRUNBY", name player]] call ACV_FNCT_BroadcastMessage;
		private ["_str","_code"];
		_str = format ["*** ACV SCRIPT par %1 *** ",name player];
		ACV_NET_Script = _str + ACV_Default_Script;
		publicVariable "ACV_NET_Script";
		sleep 0.1;
		_code = compile "diag_log ACV_NET_Script;";
		[ACV_BROADCAST_TO_SERVER,_code,_code] call ACV_FNCT_BroadcastCode;
	};
	case "raz" : {
		ACV_Default_Script = "";
		ctrlSetText [ACV_DLG_ID_Script_Edit,ACV_Default_Script];
	};
	case "copy" : {
		_entry = (missionConfigFile >> "cfgFunctions" >> "R3F_ACV") select ACV_Default_Script_category;
		_entry = (_entry ) select ACV_Default_Script_function;
		_code = getText(_entry >> "code");
		ACV_Default_Script = format ["%1 %2",ACV_Default_Script,_code];
		ctrlSetText [ACV_DLG_ID_Script_Edit,ACV_Default_Script];
	};
	case "replace" : {
		_entry = (missionConfigFile >> "cfgFunctions" >> "R3F_ACV") select ACV_Default_Script_category;
		_entry = (_entry ) select ACV_Default_Script_function;
		ACV_Default_Script = getText (_entry >> "code");
		ctrlSetText [ACV_DLG_ID_Script_Edit,ACV_Default_Script];
	};
};